<template>
	<!-- 服务评价 -->
	<view class="evaluate">
		<view class="header">
			<!-- <view class="active">服务及时</view>
			<view class="active">服务及时</view>
			<view>服务及时</view>
			<view>服务及时</view>
			<view>服务项目周到</view>
			<view>体验很好</view>
			<view>体验一般</view> -->
			<view :class="index<2 ?'active':''" v-for="(item,index) in commentTypeData" :key="item.id">
				{{item.name}}
			</view>
		</view>
		<view class="types">
			<view :class="currentid =='全部'?'active types-item':'types-item'" @click="changeTypeID('全部')">
				全部
			</view>
			<!-- <view :class="item.id ==currentid?'active types-item':'types-item'" @click="changeTypeID(item.id)"
				v-for="(item,index) in commentTypeData" :key="item.id">
				{{item.name}}({{item.count?item.count :0}})
			</view> -->
		</view>
		<!-- 评价列表 -->
		<view class="evaluateList">
			<view class="list_box" v-for="(item,index) in commentListData">
				<view class="box-l">
					<image :src="item.user_avatar" mode=""></image>
					
				</view>
				<view class="box-r">
					<text class="text1">{{item.user_nickname}}</text>
					<text class="text2">{{item.created_at}}</text>
					<uni-rate :readonly="true" :value="item.technician_score" />
				</view>
			</view>
			
		</view>

	</view>
</template>

<script>
	import {
		getType,
		getList
	} from "./api.js"
	export default {
		data() {
			return {
				imgUrl: this.$store.state.imgUrl,
				commentTypeData: [],
				commentListData: [],
				currentid: '全部',
				openid: uni.getStorageSync('token'),
			}
		},
		onLoad() {
		/* 	this.getCommentType() */
			this.getCommentList("")
		},
		methods: {
			/* getCommentType() {
				getType().then(res => {
					console.log(res,'打印的res')
					this.commentTypeData = res.data
				})

			}, */
			getCommentList(types = '') {
				/* let openid = this.openid */
				getList({
					page:1,
					limit:20

				}).then(res => {
					this.commentListData = res.data
					console.log(this.commentListData)
					
					
				})
			},
			changeTypeID(id) {
				
				this.currentid = id
				if (id == "全部") {
					this.getCommentList('')
					return
				}
				this.getCommentList(this.currentid)

			},

		}
	}
</script>

<style lang="less">
	.evaluate {
		width: 100%;
		height: 100%;
		background: #fff;

		.header {
			// height: 200rpx;
			background: #FFFFFF;
			display: flex;
			flex-wrap: wrap;
			gap: 24rpx;
			box-sizing: border-box;
			padding: 24rpx 30rpx;

			view {
				height: 64rpx;
				line-height: 64rpx;
				font-size: 24rpx;
				font-weight: 400;
				color: #999999;
				padding: 0 30rpx 0 28rpx;
				background: #F8F8F8;
				margin: 0;
				border-radius: 8rpx;

			}

			.active {
				color: #46D17E;
				background: #E8FAEF;
			}
		}

		.types {
			width: 750rpx;
			height: 88rpx;
			background: #FFFFFF;
			box-sizing: border-box;
			padding: 0 32rpx;
			display: flex;
			column-gap: 50rpx;
			border-bottom: 2rpx #F8F8F8 solid;
			border-top: 2rpx #F8F8F8 solid;

			.types-item {
				font-size: 24rpx;
				font-weight: 400;
				color: #666666;
				line-height: 88rpx;
			}

			.active {
				color: #46D17E;
			}

		}

		.evaluateList {
			.list_box{
				display: flex;
				width: 100%;
				height: 200rpx;
				padding: 20rpx;
				box-sizing: border-box;
				background-color: #fff;
				border-bottom: 1rpx solid #999;
				.box-l{
					width: 80rpx;
					height: 80rpx;
					background-color: #46D17E;
					border-radius: 50%;
					image{
						width: 100%;
						height: 100%;
						border-radius: 50%;
					}
				}
				.box-r{
					margin-left: 20rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					.text2{
						font-size: 24rpx;
						color: #999;
					}
				}
				
			}
		}
	}
</style>
